package com.it.xiaotao;

import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;

public class TestMianShi {
	private static ReentrantLock lock = new ReentrantLock();

	public static void main(String[] args) throws InterruptedException {
		print();
		new Thread(() -> {
			try {
				print();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}).start();
	}

	private static void print() throws InterruptedException {
		lock.lock();
		System.out.println("上锁了");
		TimeUnit.SECONDS.sleep(3);
		lock.unlock();
	}
}
